import 'package:flutter/material.dart';

class MyDialog extends Dialog{
  final String title;
  final String content;

  const MyDialog({super.key,required this.title,required this.content});

  @override
  Widget build(BuildContext context) {
    return Material(
      //设置背景透明
      type: MaterialType.transparency,
      child: Center(
        child: Container(
          height: 240,
          width: 240,
          color: Colors.white,
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(5),
                child: Stack(
                  children: [
                    Align(
                      alignment: Alignment.centerLeft,
                      child: Text(title,
                        style: const TextStyle(
                          fontSize: 18
                        ),
                      ),
                    ),
                    Align(
                        alignment: Alignment.centerRight,
                        child: InkWell(
                          child: const Icon(Icons.close),
                          onTap: (){
                            print("关闭");
                            Navigator.pop(context);
                          },
                        )
                    ),
                  ],
                ),
              ),
              const Divider(),
              Container(
                width: double.infinity,
                padding: const EdgeInsets.all(10),
                child: Text(content),
              )
            ],
          ),
        ),
      )
    );
  }
}
